package cn.tedu.spring2205.week02;

import cn.tedu.spring2205.week02.beans.AccountService;
import cn.tedu.spring2205.week02.beans.CustomDao;
import cn.tedu.spring2205.week02.config.Week02Config;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;

import java.awt.*;

public class Week02Test {
    public static void main(String[] args) {
        //获取到AccountServiceBean对象，获取其中的属性AccountDao
        ApplicationContext context =
                SpringApplication.run(Week02Config.class);
//        AccountService service = context.getBean(AccountService.class);
//        System.err.println(service.getAccountDao());
//        System.err.println(service.getCustomDao());
        //模拟容器强制关闭
//        try {
//            Thread.sleep(2000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        //强制关闭JVM，而JVM关闭时会自动关闭Spring容器
//        System.exit(-1);

        //BFPP测试
//        CustomDao customDao = context.getBean(CustomDao.class);
//        CustomDao customDao1 = context.getBean(CustomDao.class);
//        System.err.println(customDao1==customDao);

    }
}
